# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=hostapd-wpe
_pkgname=hostap
pkgver=2.11
pkgrel=1
pkgdesc='Modified hostapd to facilitate AP impersonation attacks.'
groups=('blackarch' 'blackarch-wireless')
arch=('x86_64' 'aarch64')
url='https://w1.fi/hostapd/'
license=('BSD-3-Clause')
depends=('glibc' 'libnl' 'openssl-1.0' 'sqlite')
makedepends=('git')
source=("git+https://w1.fi/$_pkgname.git?signed#tag=${_pkgname}_${pkgver//./_}"
        '0001_adj-wpe.patch'
        "https://raw.githubusercontent.com/aircrack-ng/aircrack-ng/master/patches/wpe/$pkgname/${_pkgname}d-$pkgver-wpe.patch")
sha512sums=('de2ba10af60bc88f0f900fe4a90681d9f08318bf12f88227881f6c4f2c4c628b89515a5425242048b8867b1791f5613fbfa1c3adeecf345aeb4093cac5eb62e4'
            '18db0425d768ebb1c2426f427570c25d3e9a5cbe26a6353b27671dd2514fed6b882c04df3f2a0de6967feca3ad4d2a925837bcc51e41723cb36d0007b509b34d'
            'c46fbd8a10045d8df09f28b37992c32b9f34604d380ff47a0158ef3afcf9b406f8788ddd8e5e1cc2478f4800de2417504d756b11ccf9628046dd8a150e1fd44c')
validpgpkeys=(EC4AA0A991A5F2464582D52D2B6EF432EFC895FA) # Jouni Malinen <j@w1.fi>

prepare() {
  # Adjust aircrack-ng patch as it doesn't cleanly apply
  patch -Np1 --follow-symlinks -i "${srcdir}"/0001_adj-wpe.patch

  # Apply aircrack-ng patch
  patch -Np1 -d $_pkgname -i "${srcdir}"/${_pkgname}d-${pkgver}-wpe.patch
}

build() {
  make -C $_pkgname/${_pkgname}d
}

package() {
  cd $_pkgname

  make -C ${_pkgname}d install DESTDIR="$pkgdir" BINDIR=/usr/bin

  install -vDm 644 COPYING -t "$pkgdir/usr/share/licenses/$pkgname/"
}

